<?php

namespace App\Modules\Admin\Http\Requests;

use App\Http\Requests\Request;

class PermissionUpdateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
            'name' => 'required|unique:permissions,name,'.$this->get('id'),',id',
            'display_name' => 'required|regex:/^[\x{4e00}-\x{9fa5}]+$/u',
        ];
    }

    public function messages()
    {
        return  [
            'name.unique' => '模块配置已经存在',
            'name.required' => '模块配置不能为空',
            'display_name.required' => '模块名称不能为空',
            'display_name.regex' => '模块名称只能为中文',
        ];
    }
}
